<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
    template="../templates/ui.xhtml">
    
        
    <ui:define name="head">
        <style type="text/css">

        </style>
        
        <script type="text/javascript">
//<![CDATA[

//]]>
        </script>
    </ui:define>

	<ui:define name="content">
		<h1 class="title ui-widget-header ui-corner-all">TreeTable - Resizable Columns</h1>

		<div class="entry">
            <p>TreeTable columns can be resized by dragging.</p>
		
			<h:form id="form">
                
                <h:panelGrid columns="2">
                    <p:outputLabel for="resizeMode" value="Resize Mode:" />
                    <p:selectOneButton id="resizeMode" value="#{documentsController.liveResize}" onchange="$('#form').submit()">
                        <f:selectItem itemLabel="Default" itemValue="#{false}" />
                        <f:selectItem itemLabel="Live" itemValue="#{true}" />
                    </p:selectOneButton>
                </h:panelGrid>
                
                <br />
	
				<p:treeTable id="treetable" value="#{documentsController.root}" var="document" resizableColumns="true" liveResize="#{documentsController.liveResize}">
                    <f:facet name="header">
                        Document Viewer
                    </f:facet>
                    
					<p:column headerText="Name">
						<h:outputText value="#{document.name}" />
					</p:column>
					
					<p:column headerText="Size">
						<h:outputText value="#{document.size}" />
					</p:column>
					
					<p:column headerText="Type">
						<h:outputText value="#{document.type}" />
					</p:column>
				</p:treeTable>
				
			</h:form>
			
			<h3>Source</h3>
			<p:tabView>
				<p:tab title="treeTableResizable.xhtml">
					<pre name="code" class="xml">
&lt;h:form id="form"&gt;

    &lt;h:panelGrid columns="2"&gt;
        &lt;p:outputLabel for="resizeMode" value="Resize Mode:" /&gt;
        &lt;p:selectOneButton id="resizeMode" value="\#{documentsController.liveResize}" onchange="$('\#form').submit()"&gt;
            &lt;f:selectItem itemLabel="Default" itemValue="\#{false}" /&gt;
            &lt;f:selectItem itemLabel="Live" itemValue="\#{true}" /&gt;
        &lt;/p:selectOneButton&gt;
    &lt;/h:panelGrid&gt;
	
    &lt;p:treeTable id="treetable" value="\#{documentsController.root}" var="document" resizableColumns="true"&gt;
        &lt;f:facet name="header"&gt;
            Document Viewer
        &lt;/f:facet&gt;

        &lt;p:column headerText="Name"&gt;
            &lt;h:outputText value="\#{document.name}" /&gt;
        &lt;/p:column&gt;

        &lt;p:column headerText="Size"&gt;
            &lt;h:outputText value="\#{document.size}" /&gt;
        &lt;/p:column&gt;

        &lt;p:column headerText="Type"&gt;
            &lt;h:outputText value="\#{document.type}" /&gt;
        &lt;/p:column&gt;
    &lt;/p:treeTable&gt;

&lt;/h:form&gt;
					</pre> 
				</p:tab>
				
				<p:tab title="DocumentsController.java">
					<pre name="code" class="java">
package org.primefaces.examples.view;

import java.io.Serializable;

import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

import org.primefaces.examples.domain.Document;

public class DocumentsController implements Serializable {
	
	private static final Logger logger = Logger.getLogger(DocumentsController.class.getName());

	private TreeNode root;

	private Document selectedDocument;

    private boolean liveResize;
	
	public DocumentsController() {
		root = new DefaultTreeNode("root", null);
		
		TreeNode documents = new DefaultTreeNode(new Document("Documents", "-", "Folder"), root);
		TreeNode pictures = new DefaultTreeNode(new Document("Pictures", "-", "Folder"), root);
		TreeNode music = new DefaultTreeNode(new Document("Music", "-", "Folder"), root);
		
		TreeNode work = new DefaultTreeNode(new Document("Work", "-", "Folder"), documents);
		TreeNode primefaces = new DefaultTreeNode(new Document("PrimeFaces", "-", "Folder"), documents);
		
		//Documents
		TreeNode expenses = new DefaultTreeNode("document", new Document("Expenses.doc", "30 KB", "Word Document"), work);
		TreeNode resume = new DefaultTreeNode("document", new Document("Resume.doc", "10 KB", "Word Document"), work);
		TreeNode refdoc = new DefaultTreeNode("document", new Document("RefDoc.pages", "40 KB", "Pages Document"), primefaces);
		
		//Pictures
		TreeNode barca = new DefaultTreeNode("picture", new Document("barcelona.jpg", "30 KB", "JPEG Image"), pictures);
		TreeNode primelogo = new DefaultTreeNode("picture", new Document("logo.jpg", "45 KB", "JPEG Image"), pictures);
		TreeNode optimus = new DefaultTreeNode("picture", new Document("optimusprime.png", "96 KB", "PNG Image"), pictures);
		
		//Music
		TreeNode turkish = new DefaultTreeNode(new Document("Turkish", "-", "Folder"), music);
		
		TreeNode cemKaraca = new DefaultTreeNode(new Document("Cem Karaca", "-", "Folder"), turkish);
		TreeNode erkinKoray = new DefaultTreeNode(new Document("Erkin Koray", "-", "Folder"), turkish);
		TreeNode mogollar = new DefaultTreeNode(new Document("Mogollar", "-", "Folder"), turkish);
		
		TreeNode nemalacak = new DefaultTreeNode("mp3", new Document("Nem Alacak Felek Benim", "1500 KB", "Audio File"), cemKaraca);
		TreeNode resimdeki = new DefaultTreeNode("mp3", new Document("Resimdeki Gozyaslari", "2400 KB", "Audio File"), cemKaraca);
		
		TreeNode copculer = new DefaultTreeNode("mp3", new Document("Copculer", "2351 KB", "Audio File"), erkinKoray);
		TreeNode oylebirgecer = new DefaultTreeNode("mp3", new Document("Oyle bir Gecer", "1794 KB", "Audio File"), erkinKoray);
		
		TreeNode toprakana = new DefaultTreeNode("mp3", new Document("Toprak Ana", "1536 KB", "Audio File"), mogollar);
		TreeNode bisiyapmali = new DefaultTreeNode("mp3", new Document("Bisi Yapmali", "2730 KB", "Audio File"), mogollar);
	}
	
	public TreeNode getRoot() {
		return root;
	}
	
	public Document getSelectedDocument() {
		return selectedDocument;
	}

	public void setSelectedDocument(Document selectedDocument) {
		this.selectedDocument = selectedDocument;
	}

    public boolean isLiveResize() {
        return liveResize;
    }
    public void setLiveResize(boolean liveResize) {
        this.liveResize = liveResize;
    }
}
					</pre>
				</p:tab>
			</p:tabView>
		</div>

	</ui:define>
</ui:composition>